/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package relatorio.cliente;

import camada.bancodedados.conexao.Conexao;
import java.io.InputStream;
import java.sql.Connection;
import java.util.Hashtable;
import java.util.logging.Level;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.view.JasperViewer;
import org.jdesktop.swingx.error.ErrorInfo;
import utilitarios.erros.MessagemErro;

/**
 *
 * @author Ícaro
 */
public class ReportCliente {

    private static Connection con;
    
    public ReportCliente() {
        
        try {
            
            Hashtable parametros = new Hashtable();

             con = Conexao.getCon();
            
            parametros.put("IDCONTABANCARIA", "");

            JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(null);

            String caminhoRelJasper = "reportListaTelefonica.jasper";

            InputStream relJasper = this.getClass().getResourceAsStream(caminhoRelJasper);

            JasperPrint impressao;
            impressao = JasperFillManager.fillReport(relJasper, parametros, con);
            JasperViewer viewer = new JasperViewer(impressao, false);
            viewer.setVisible(true);
            viewer.setExtendedState(javax.swing.JFrame.MAXIMIZED_BOTH);
            
        } catch (Exception e) {
            MessagemErro erro = new MessagemErro(new ErrorInfo("Erro no Sistema", "Não é Possível Continuar, Sistema Inativo", null, "Fatal", e, Level.WARNING, null), 1);
        }
    }

}
